// eslint-disable-next-line
import { UserLayout, BasicLayout, BlankLayout } from '@/layouts'

const RouteView = {
  name: 'RouteView',
  render: h => h('router-view')
}

export const asyncRouterMap = [
  {
    path: '/',
    name: 'index',
    component: BasicLayout,
    meta: { title: 'menu.home' },
    redirect: '/music/myPlaylist',
    children: [
      {
        path: '/findMusic/musicSquare',
        name: 'musicSquare',
        hideChildrenInMenu: true, // 强制显示 MenuItem 而不是 SubMenu
        component: () => import('@/views/music/MusicSquare'),
        meta: { title: '音乐广场', icon: 'api', keepAlive: false, permission: [ 'music' ] }
      },
      // 发现音乐
      {
        path: '/findMusic',
        name: 'findMusic',
        component: RouteView,
        hidden: true,
        redirect: '/findMusic/musicSquare',
        meta: { title: '发现音乐', icon: 'search', keepAlive: false, permission: [ 'music' ] },
        children: [
          {
            path: '/findMusic/playlistDetail',
            name: 'playlistDetail',
            hideChildrenInMenu: true, // 强制显示 MenuItem 而不是 SubMenu
            hidden: true,
            component: () => import('@/views/music/PlaylistDetail'),
            meta: { title: '歌单详情', icon: 'api', keepAlive: false, permission: [ 'music' ] }
          },
          {
            path: '/findMusic/othersCenter',
            name: 'othersCenter',
            hideChildrenInMenu: true, // 强制显示 MenuItem 而不是 SubMenu
            hidden: true,
            component: () => import('@/views/music/OthersCenter'),
            meta: { title: '他人信息', icon: 'api', keepAlive: false, permission: [ 'music' ] }
          },
          {
            path: '/findMusic/searchList',
            name: 'searchList',
            hideChildrenInMenu: true, // 强制显示 MenuItem 而不是 SubMenu
            hidden: true,
            component: () => import('@/views/music/SearchList'),
            meta: { title: '搜索', icon: 'api', keepAlive: false, permission: [ 'music' ] }
          }
        ]
      },
      {
        path: '/music',
        name: 'music',
        component: RouteView,
        redirect: '/music/myPlaylist',
        meta: { title: '我的资源', icon: 'database', keepAlive: false, permission: [ 'music' ] },
        children: [
          {
            path: '/music/myPlaylist',
            name: 'myPlaylist',
            component: () => import('@/views/music/MyPlaylist'),
            meta: { title: '我的歌单', icon: 'align-left', keepAlive: false, permission: [ 'music-MyPlaylist' ] }
          },
          {
            path: '/music/mySong',
            name: 'mySong',
            hideChildrenInMenu: true, // 强制显示 MenuItem 而不是 SubMenu
            hidden: true,
            component: () => import('@/views/music/MySong'),
            meta: { title: '我的歌', icon: 'api', keepAlive: false, permission: [ 'music-mySong' ] }
          }
        ]
      },
      // 我的收藏
      {
        path: '/collection',
        name: 'collection',
        component: RouteView,
        redirect: '/collection/playlist',
        meta: { title: '我的收藏', icon: 'folder-add', keepAlive: false, permission: [ 'music' ] },
        children: [
          {
            path: '/collection/playlist',
            name: 'collectionPlaylist',
            hideChildrenInMenu: true, // 强制显示 MenuItem 而不是 SubMenu
            component: () => import('@/views/music/CollectionPlaylist'),
            meta: { title: '收藏歌单', icon: 'api', keepAlive: false, permission: [ 'music' ] }
          },
          {
            path: '/collection/song',
            name: 'collectionSong',
            hideChildrenInMenu: true, // 强制显示 MenuItem 而不是 SubMenu
            component: () => import('@/views/music/CollectionSong'),
            meta: { title: '收藏歌曲', icon: 'heart', keepAlive: false, permission: [ 'music' ] }
          }
        ]
      },
      // 我的下载
      {
        path: '/download',
        name: 'download',
        component: () => import('@/views/music/Download'),
        // redirect: '/collection/playlist',
        meta: { title: '我的下载', icon: 'download', keepAlive: false, permission: [ 'music' ] }
      },
      // 个人中心
      {
        path: '/selfCenter',
        name: 'selfCenter',
        component: () => import('@/views/music/SelfCenter'),
        meta: { title: '个人中心', icon: 'user', keepAlive: false, permission: [ 'music' ] }
      },
      // 编辑个人信息
      {
        path: '/editSelfInfo',
        name: 'editSelfInfo',
        component: () => import('@/views/music/modules/selfCenter/EditSelfInfo'),
        hidden: true,
        meta: { title: '个人中心', icon: 'build', keepAlive: false, permission: [ 'music' ] }
      },
      // 路由跳转中转站
      {
        path: '/userList',
        name: 'userList',
        hideChildrenInMenu: true, // 强制显示 MenuItem 而不是 SubMenu
        hidden: true,
        component: () => import('@/views/user/UserList'),
        meta: { title: '用户列表', icon: 'build', keepAlive: false, permission: [ 'music' ] }
      },
      // 路由跳转中转站
      {
        path: '/transferPage',
        name: 'transferPage',
        hideChildrenInMenu: true, // 强制显示 MenuItem 而不是 SubMenu
        hidden: true,
        component: () => import('@/views/transfer/TransferPage'),
        meta: { title: '？', icon: 'build', keepAlive: false, permission: [ 'music' ] }
      }
    ]
  },
  {
    path: '*',
    redirect: '/404',
    hidden: true
  }
]

/**
 * 基础路由
 * @type { *[] }
 */
export const constantRouterMap = [
  {
    path: '/user',
    component: UserLayout,
    redirect: '/user/login',
    hidden: true,
    children: [
      {
        path: 'login',
        name: 'login',
        component: () => import(/* webpackChunkName: "user" */ '@/views/user/Login')
      },
      {
        path: 'register',
        name: 'register',
        component: () => import(/* webpackChunkName: "user" */ '@/views/user/Register')
      },
      {
        path: 'register-result',
        name: 'registerResult',
        component: () => import(/* webpackChunkName: "user" */ '@/views/user/RegisterResult')
      },
      {
        path: 'recover',
        name: 'recover',
        component: undefined
      }
    ]
  },

  {
    path: '/404',
    component: () => import(/* webpackChunkName: "fail" */ '@/views/exception/404')
  }
]
